<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Trang đăng nhập</title>
<style type="text/css">
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.corner.js"></script>

<script> 
$(document).ready(function()
 { 
 $("#dn").corner ("10px");
 
 //$("#sp").corner("dog2 30px");
}); 
</script>
</head>

<body>
<?php
include("kn.php");
if(isset($_POST["user"])&&isset($_POST["pass"]))
{
	$user = $_POST["user"];
	$pass = md5($_POST["pass"]);
	$lenh = "select * from khachhang where user = '$user' and matkhau = '$pass'";
	$kq = mysql_query($lenh);
	$n = mysql_num_rows($kq);
	if($n >0)
	{
		$_SESSION["user"]=$user;
		?>
        <script>
		alert('Bạn đăng nhập thành công!');
		</script>
        <?php
	}
	else
	{
		?>
        <script>
		alert('Bạn đăng nhập thất bại!');
		</script>
        <?php
	}
	
	
}
if(!$_SESSION["user"])
{
echo"<form id='form1' name='form1' method='post' action=''>
  <table width='100%' border='1' align='center' cellpadding='0' cellspacing='0' style='border-collapse:collapse' bgcolor='#FFFF99' bordercolor='#FFFF66' id='dn2'>
    <tr>
      <td width='74' align='center' bgcolor='#9999FF'>User</td>
      <td width='120' align='center' bgcolor='#9999FF'><label for='user'></label>
      <input name='user' type='text' id='user' size='15'/></td>
    </tr>
    <tr>
      <td align='center' bgcolor='#9999FF'>Pass</td>
      <td align='center' bgcolor='#9999FF'><label for='pass'></label>
      <input name='pass' type='password' id='pass' size='15'/></td>
    </tr>
    <tr>
      <td height='35' colspan='2' align='center' bgcolor='#9999FF'><input type='submit' name='dn' id='dn' value='Đăng nhập' /></td>
	 
    </tr>
	 
  </table>
  
	 <center > <a href='index.php?act=dk'>Đăng ký</a></center>
</form>";
}
else
{
	include("kn.php");
	$lenh1 = "select * from khachhang where user = '".$_SESSION["user"]."'";
	$kq1 = mysql_query($lenh1);
	$row1 = mysql_fetch_assoc($kq1);
	?>
    <center>
    <?php
	if($row1[Macv]==0)
	{
	echo "Chào bạn ".$row1['Tenkhachhang']."<br>";
	echo"<a href='thoat.php'>Thoát</a>";
	}
	else
	{
		echo "Chào bạn ".$row1['Tenkhachhang']."<br>";
	echo"<a href='thoat.php'>Thoát</a>"." | ";
	echo"<a href='index.php?act=qt'>Quản trị</a>";
	}
	?>
    <br />
    
    </center>
    <?php
}
?>

</body>
</html>